<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/ajax.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
    
    <style>
        .item{
            border: 1px solid #333;
        }
        .item img{
            width: 100px;
            height: 100px;
        }
    </style>
</head>
<body>
    <div id="app"></div>
    <script>
        var url = 'http://47.108.197.28:3000/top/playlist?cat=华语'
        $ajax( {
                url,
                success:res=>{
                    var playlists = res.playlists;
                    playlists.forEach(item => {
                        var {name,id,coverImgUrl} =item;
                        var template = `
                        
                            <div class='item' data-aid = ${id}>
                            <img src = "${coverImgUrl}">
                            <p>${name}</p>
                       
                        `
                        $("#app").append(template)
                    });
                    $(".item").click(function(event){
                        var {aid} = event.currentTarget.dataset
                        location.href = `detail.html?id=${aid}`
                    })
                }
            }
           
        )
    </script>
</body>
</html>